#include<iostream>
#include<algorithm>
using namespace std;

typedef long long ll;
const int N = 2e5 + 10;
ll arr[N];
ll n, c;
ll ret;

int binary_search(int b){
	ll l = 1, r = n;
	while(l < r){
		ll mid = (l + r) / 2;
		if(arr[mid] >= b) r = mid;
		else l = mid + 1;
	}
	if(arr[l] != b) return 0;
	ll retleft = l;
	l = 1, r = n;
	while(l < r){
		ll mid = (l + r + 1) / 2;
		if(arr[mid] <= b) l = mid;
		else r = mid - 1;
	}
	return l - retleft + 1;
}

int main(){
	cin >> n >> c;
	for(int i = 1; i <= n; i++) cin >> arr[i];
	sort(arr + 1, arr + n + 1);
	for(int i = 1; i <= n; i++){
		ll a, b;
		a = arr[i];
		b = a - c;
		ret +=binary_search(b);
	}
	cout << ret << endl;
	return 0;
} 
